import sheep from '@/sheep';
import { formatImageUrlProtocol } from './index';
import { baseUrl, h5_url } from '@/sheep/config';

const user = (poster) => {
  const width = poster.width;
  const userInfo = sheep.$store('user').userInfo;

  return {
    background: formatImageUrlProtocol(sheep.$url.cdn(sheep.$store('app').platform.share.posterInfo.user_bg)),
    list: [
      {
        name: 'nickname',
        type: 'text',
        val: userInfo.nickname,
        x: width / 3.8,
        y: width * 1.35,
        paintbrushProps: {
          textAlign: 'left',
          fillStyle: '#333',
          font: {
            fontSize: 18,
            fontFamily: 'sans-serif',
            fontWeight: 'bold',
          },
        },
      },
      {
        name: 'sq_code',
        type: 'text',
        val: `拾亲号: ${userInfo.uid}`,
        x: width / 3.8,
        y: width * 1.41,
        paintbrushProps: {
          textAlign: 'left',
          fillStyle: '#9F9F9F',
          font: {
            fontSize: 16,
            fontFamily: 'sans-serif',
            fontWeight: '500',
          },
        },
      },
      {
        name: 'introduce',
        type: 'text',
        val: '邀请您免费加入拾亲',
        x: width / 3.8,
        y: width * 1.47,
        paintbrushProps: {
          textAlign: 'left',
          fillStyle: '#9F9F9F',
          font: {
            fontSize: 16,
            fontFamily: 'sans-serif',
            fontWeight: '500',
          },
        },
      },
      {
        name: 'avatar',
        type: 'image',
        val: formatImageUrlProtocol(sheep.$url.cdn(userInfo.avatar)),
        x: width * 0.06,
        y: width * 1.33,
        width: width * 0.18,
        height: width * 0.18,
        d: width * 0.18,
      },
      // #ifdef H5
      {
        name: 'qrcode',
        type: 'qrcode',
        val: h5_url + `/#/pages/message/genealogy?spid=${JSON.parse(uni.getStorageSync('user-store')).userInfo.uid}`,
        x: width * 0.73,
        y: width * 1.34,
        size: width * 0.2,
      },
      {
        name: 'description',
        type: 'text',
        val: '拾亲H5',
        x: width / 1.28,
        y: width * 1.55,
        paintbrushProps: {
          textAlign: 'left',
          fillStyle: 'rgba(159,159,159,0.85)',
          font: {
            fontSize: 10,
            fontFamily: 'sans-serif',
            fontWeight: '400',
          },
        },
      },
      // #endif
      // #ifdef APP-PLUS
      {
        name: 'qrcode',
        type: 'qrcode',
        val: h5_url + `/#/pages/public/download?spid=${JSON.parse(uni.getStorageSync('user-store')).userInfo.uid}`,
        x: width * 0.73,
        y: width * 1.34,
        size: width * 0.2,
      },
      {
        name: 'description',
        type: 'text',
        val: '拾亲APP',
        x: width / 1.28,
        y: width * 1.55,
        paintbrushProps: {
          textAlign: 'left',
          fillStyle: 'rgba(159,159,159,0.85)',
          font: {
            fontSize: 10,
            fontFamily: 'sans-serif',
            fontWeight: '400',
          },
        },
      },
      // #endif
      // #ifdef MP-WEIXIN
      {
        name: 'wxacode',
        type: 'image',
        val: sheep.$api.third.wechat.getWxacode(poster.shareInfo.path),
        x: width * 0.73,
        y: width * 1.34,
        width: width * 0.18,
        height: width * 0.18,
      },
      {
        name: 'description',
        type: 'text',
        val: '拾亲小程序',
        x: width / 1.21,
        y: width * 1.53,
        paintbrushProps: {
          textAlign: 'center',
          fillStyle: 'rgba(159,159,159,0.85)',
          font: {
            fontSize: 10,
            fontFamily: 'sans-serif',
            fontWeight: '400',
            textAlign: 'center',
          },
        },
      },
      // #endif

    ],
  };
};

export default user;
